\newcommand{\spuselatex}[1]{
    \usepackage[utf8x]{inputenc}
    \usepackage[#1]{babel}
}

\newcommand{\spusexelatex}[1]{
 \ifpackageavailable{xunicode xltxtra fontspec polyglossia}
 {
  	  \usepackage{xunicode}
  	  \usepackage{xltxtra}
  	  \usepackage{fontspec}
  	  \usepackage{polyglossia}
 
      \setdefaultlanguage{#1}
  	  \defaultfontfeatures{Mapping=tex-text}
  	  
  	  \newcommand{\og}{«}
  	  \newcommand{\fg}{»}
  }
  {}
}

\newcommand{\splanguage}[1]
{
  \fetchpackage{algorithm2e}
  \usepackage[#1, boxruled, linesnumbered, vlined]{algorithm2e}

  \ifpackageavailable{ifxetex}{
    \usepackage{ifxetex}

    \ifthenelse{\boolean{xetex}}{
      \spusexelatex{#1}
    }{
      \spuselatex{#1}
    }
  }
  { \spuselatex{#1} }
}
